<link rel="stylesheet" href="/assets/assets(home)/css/coupon_list.css" />
<title>优惠券</title>


<!-- <header class="mui-bar mui-bar-nav mui-bar-nav-bg">
    <a id="icon-menu" class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
    <h1 class="mui-title">优惠券</h1>
</header> -->

{if condition="$list"}
<div class="coupon_list">
    {foreach $list as $item}
    <div class="coupon_item">
        <div class="item_content">
            <a href="{:url('home/coupon/coupon_info', ['cid' => $item['id']])}">
                <div class="left">
                    {$item.rate * 100}<span>折</span>
                </div>
                <div class="right">
                    <div>{$item.title}</div>
                    <div>凭此券购买课程可减免<span>{$item.rate * 100}</span>%</div>
                    <div>每人限领1张</div>
                    <div>领取后{$item.endtime / 86400 - $item.createtime / 86400}天内有效</div>
                </div>
            </a>
        </div>
        <div class="item_btn">
            {if condition="$item.receive"}
            <a href="{:url('home/coupon/receive', ['cid' => $item['id']])}" class="mui-btn mui-btn-danger">待领取</a>
            {else /}
            <a class="mui-btn right_btn">已领取</a>
            {/if}
        </div>
    </div>
    {/foreach}
</div>
{/if}

<script>
    //修改浏览器自带的后退按钮
    window.history.pushState(null, null, ``);

    window.addEventListener('popstate', function (e) {
        e.preventDefault()
        location.href = `{:url('/home/index/index')}`
    }, false)
</script>